﻿Imports System.Net
Imports System.Net.mail

Public Class SMTPMailHelper
    Const SMTPServer As String = "smtp.gmail.com "
    Const SMTPUserId As String = "joko.matriano"
    Const SMTPPassword As String = "2429sparco"
    Const SMTPPort As Integer = 25
    Public Shared Sub SendMail(ByVal sendFrom As String,
                               ByVal sendTo As String,
                               ByVal subject As String,
                               ByVal body As String)
        Dim fromAddress = New MailAddress(sendFrom)
        Dim toAddress = New MailAddress(sendTo)
        Dim mail As New MailMessage

        With mail
            .From = fromAddress
            .To.Add(toAddress)
            .Subject = subject

            If body.ToLower.Contains("<html>") Then
                .IsBodyHtml = True
            End If

            .Body = body
        End With

        Dim smtp As New SmtpClient(SMTPServer, SMTPPort)
        smtp.Credentials = New NetworkCredential(SMTPUserId, SMTPPassword)
        smtp.Send(mail)
    End Sub
End Class
